%{
#include <string.h>
char    **f_stunstr, **f_port, **f_proxy, **f_username, **f_password;

%}

PHRASE .+

%%
"username="{PHRASE}		{	(*f_username)=strdup(strlen("username=")+yytext);			}
"password="{PHRASE}		{	(*f_password)=strdup(strlen("password=")+yytext);			}
"stun="{PHRASE}			{	(*f_stunstr)=strdup(strlen("stun=")+yytext);				}
"port="{PHRASE}			{	(*f_port)=strdup(strlen("port=")+yytext);				}
"proxy="{PHRASE}		{	(*f_proxy)=strdup(strlen("proxy=")+yytext);				}

[ \t\n]*
#.+

%%

int parse_configfile(char **stunstr, char **port, char **proxy, char **username, char **password, char** configfilepath)
{          
	f_stunstr=stunstr;
	f_port=port;
	f_proxy=proxy;
	f_username=username;
	f_password=password;


	yyin = fopen((const char*)configfilepath, "r");
	if(NULL == yyin)
	{
		fprintf(stderr, "failed to open file \"%s\"\n", *configfilepath);
		return 1;
	}
	yylex();
	return 0;
}
